#include <unistd.h>
#include <signal.h>
#include <sys/types.h>
#include <fcntl.h>
#include <string.h>
#include "config.h"
#include "findhome.h"

int main (int argc, char **argv, char **env)
{
	char main_pid_file [32];
	pid_t pid;
	int fd;
	char *home = findhome(env);

	(void) argc;
	(void) argv;
	
	/*
	 * Find the path to the PID file.
	 */
	strncpy (main_pid_file, home, 32);
	strncat (main_pid_file, MAIN_PID_FILE, 32);

	fd = open (main_pid_file, O_RDONLY);
	read (fd, &pid, sizeof(pid_t));
	close (fd);

	kill (pid, SIGTERM);

	return 0;
}

